/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.base.jpa.entity;

import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Transient;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.Comment;
import org.hibernate.envers.AuditOverride;

/**
 *
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@AuditOverride(forClass = BaseEntity.class, isAudited = true)
@MappedSuperclass
public abstract class BaseTreeEntity extends BaseEntity {

    @Comment("名称")
    @Column(name = "name", length = 50)
//    @NotNull
    private String name;
    @Comment("父ID")
    @Column(name = "pid", nullable = true)
    private Long pid;
    @Transient
    private BaseTreeEntity parent;

    @Comment("排序值")
    @Column(name = "sort")
    private Integer sort;

    @Comment("层级值")
    @Column(name = "level")
    private Integer level;

    @Comment("备注")
    @Column(name = "remark", length = 500)
    private String remark;

//    @Transient
    public abstract boolean isHasChildren();

//    @Override
    public void setId(Long id) {
        super.setId(id); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody
    }
}
